<template>
	<view>
		<view class="account_box" v-if="data !== undefined && data!== null && data .length>0">
			<view class="account_list" v-for="(item,index) in data" :key="index">
				<view class="account_cont">
					<text
						v-if="item.order_info">{{item.order_info.merchant_name}}[{{item.order_info.tran_amount}}]</text>
					<view class="">
						<text v-if="item.order_num">{{item.order_num}}</text>
						<u--text mode="date" :text="item.create_time" align="left" margin="20rpx 0 0 0 " color="#999999" ></u--text>
					</view>
				</view>
				<view class="increase">+{{item.changes}} <text>元</text></view>
			</view>
		</view>
		<u-empty v-else mode="list" icon="/static/Empty/data_null.png">
		</u-empty>
	</view>
</template>

<script>
	import screen from '@/component/screen.vue';
	export default {
		components: {
			screen
		},
		data() {
			return {
				tab: [],
				current: 0,
				data: [],
				page: 1,
				bottom: true,
				start: false,
				start_text: '选择开始日期',
				start_value: Number(new Date()),
				start_time: '',
				end: false,
				end_text: '选择结束日期',
				end_value: Number(new Date()),
				end_time: '',
				id: ''
			}
		},
		onLoad(e) {
			this.id = e.id
			this._List()
		},
		//下拉刷新
		onReachBottom() {
			if (this.bottom == true) {
				this.page += 1
				this._List()
			}
		},
		methods: {
			// 页面列表展示
			async _List() {
				uni.showLoading({
					title: '加载中'
				});
				const {
					data: res
				} = await this.$myHttp({
					url: 'v1/getMoneyLog',
					data: {
						type: this.id,
						page: this.page,
						page_size: 15,
					}
				});
				if (res.code == 200) {
					if (res.data !== undefined && res.data !== null && res.data.length >
						0) {
						if (this.page == 1) {
							this.data = res.data
							uni.hideLoading()
						} else {
							this.data = [...this.data, ...res.data]
							uni.hideLoading()
						}
					} else {
						uni.hideLoading()
						this.bottom = false
					}
				} else {
					uni.showToast({
						title: res.msg,
						duration: 1000,
						icon: "none"
					});
					this.bottom = false
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.on-screen {
		display: flex;
		align-items: center;
		justify-content: flex-end;
		margin-right: 30rpx;
		box-sizing: border-box;

		text {
			margin-right: 20rpx;
			color: #333;
		}
	}

	.balance {
		display: flex;
		flex-direction: column-reverse;
		padding: 20rpx 30rpx 50rpx 30rpx;
		box-sizing: border-box;

		.balance_top {
			display: flex;
			flex-direction: column;
			align-items: center;
			width: 100%;

			text {
				font-size: 24rpx;
				color: #666666;
			}

			h2 {
				font-weight: 500;
				margin-top: 10rpx;
				margin-bottom: 30rpx;
				font-size: 42rpx;
			}
		}


		.expenses {
			display: flex;
			margin-bottom: 30rpx;
			box-sizing: border-box;
			align-items: center;
			justify-content: center;

			.dbs {
				// width: 100%;
			}

			.expenses_time {
				display: flex;
				justify-content: flex-start;
				align-items: center;

				.order {
					color: #fff;
					font-size: 28rpx;
					padding: 5rpx 20rpx;
					background-color: #1e80ff;
					border-radius: 15rpx;
					margin-left: 50rpx;
				}
			}

			text {
				font-size: 24rpx;
				color: #999999;
			}
		}
	}

	.account_box {
		padding:  30rpx;

		.account_list {
			border: #e5e5e5 1px solid;
			border-radius: 15rpx;
			padding: 25rpx;
			// padding-bottom: 0;
			margin-bottom: 30rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.account_cont {
				display: flex;
				flex-direction: column;

				text {
					color: #333;
					font-size: 24rpx;
					margin-bottom: 20rpx;
				}
			}

			.increase {
				color: #d30000;
				font-size: 34rpx;

				text {
					color: #333;
					font-size: 24rpx;
					margin-left: 10rpx;
				}
			}
		}
	}
</style>
